﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VideoCache.Server.BLL
{
    class CacheBLL
    {
        private static Dictionary<string, object> cacheList = new Dictionary<string, object>();

        public static T GetCache<T>(string key)
        {
            if (cacheList.ContainsKey(key.ToLower()))
            {
                return (T)cacheList[key.ToLower()];
            }

            return default(T);
        }

        public static void CreateCache(string key, object obj)
        {
            if (cacheList.ContainsKey(key.ToLower())) throw new ArgumentException("指定的缓存对象已存在。");

            cacheList.Add(key.ToLower(), obj);
        }

        public static bool Contains(string key)
        {
            return cacheList.ContainsKey(key.ToLower());
        }
    }
}